// 表单全局属性
let formGlobalJson = {
  id: "form-uuid",
  title: "表单标题",
  description: "表单描述",
  hidden: false,
  disabled: false,
  props: {
    labelWidth: "100px",
    labelPosition: "right",
    size: "large",
    disabled: false,
  },
  rules: {
    "input-uuid-1-name": [
      {
        required: true,
        message: "请输入姓名",
        trigger: "blur",
      },
    ],
  },
}
// 表单字段通用属性
let fieldCommonProps = {
  hidden: false,
  readonly: false,
  disabled: false,
  // 显隐表达式(遵循jsonLogic语法，受控字段)
  showExpression: "",
  // 值联动（A）
  // valueLinkage: {
  //   fieldId: "input-uuid-4",
  //   relationType: "eq", // eq:等于,neq:不等于,gt:大于,gte:大于等于,lt:小于,lte:小于等于,contains:包含,notContains:不包含,startsWith:以...开头,endsWith:以...结尾,is:是,isNot:不是,isBlank:为空,isNotBlank:不为空
  //   relationValue: "123",
  //   relationValue2: "456",
  // },
}
/**
 *  name: 字段名称 默认显示为字段id，可修改
 *  id: 字段id 唯一标识
 *  type: 字段类型 如：fc-input,fc-select,fc-row等
 *  label: 字段标签 如：姓名
 *  commonProps: 字段通用属性 如：hidden,readonly,disabled,required等
 *  props: 字段组件属性 如：placeholder,maxlength,minlength等
 *  rules: 字段验证规则 如：required,message等
 *  children: 字段子元素 如：fc-input,fc-select,fc-row等，可嵌套
 * */ 



export const json = {
  formGlobalJson,
  fields: [
    // 栅格化布局
    {
      id: "row-uuid-1",
      type: "FcLayoutRow",
      name: "row-uuid-1-name",
      label: "栅格化布局",
      commonProps: {
        ...fieldCommonProps,
      },
      // 组件属性
      props: {
        gap: 0,
        col: "12:12",
      },
      
      children: [
        {
          id: "input-uuid-1",
          type: "FcFormInput",
          label: "姓名1",
          name: "input-uuid-1-name",
          // 通用属性
          commonProps: {
            ...fieldCommonProps,
            showExpression:  { "or" : [
              {"==" : [ { "var" : "input-uuid-2-name" },{ "var" : "input-uuid-3-name" } ] },
              {"==" : [ { "var" : "input-uuid-2-name" },"zhao" ] }
            ]}
          },
          // 组件属性
          props:{
            clearable:true,
          },
          // 组件事件
          events:{
            input:(e)=>{
              console.log(e)
            },
            clear:()=>{
              console.log("clear")
            }
          }
        },
        {
          id: "row-uuid-2",
          type: "FcLayoutRow",
          name:"row-uuid-2-name",
          label: "栅格化布局",
          // 通用属性
          commonProps: {
            ...fieldCommonProps,
          },
          // 组件属性
          props: {
            gap: 0,
            col: "12:12",
          },
          children: [
            {
              id: "input-uuid-2",
              type: "FcFormInput",
              label: "姓名2",
              name: "input-uuid-2-name",
              // 通用属性
              commonProps: {
                ...fieldCommonProps,
              },
              events:{
                // 事件参数：value,node
                input:(value,node,formRenderControl)=>{
                  console.log(value,node,formRenderControl)
                },
                clear:()=>{
                  console.log("clear")
                }
              }
            },
            {
              id: "input-uuid-3",
              type: "FcFormInput",
              label: "姓名3",
              name: "input-uuid-3-name",
            },
          ],
        },

      ],
    },

    {
      id: "input-uuid-4",
      type: "FcFormInput",
      label: "姓名",
      name: "input-uuid-4-name",
      // 通用属性
      commonProps: {
        ...fieldCommonProps,
      },
      // 组件属性
      props: {
        placeholder: "请输入姓名",
        maxlength: 10,
        minlength: 2,
      },
      // 验证规则
      rules: [
        {
          required: true,
          message: "请输入姓名",
        },
      ],
    },
    {
      id: "select-uuid-1",
      type: "FcSelect",
      label: "性别",
      name: "select-uuid-1-name",
      // 通用属性
      commonProps: {
        ...fieldCommonProps,
      },
      // 组件属性
      props: {
        placeholder: "请选择性别",
        options: [
          {
            label: "男",
            value: "male",
          },
          {
            label: "女",
            value: "female",
          },
        ],
        multiple: false,
        clearable: true,
        filterable: true,
        remote: false,
        remoteMethod: () => { },
        remoteSearch: false,
      },
      // 验证规则
      rules: [
        {
          required: true,
          message: "请输入姓名",
        },
      ],
    },
  ],
}